package com.define.ssh.action.admin;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.apache.struts2.convention.annotation.ParentPackage;

import com.define.ssh.service.UserInfoService;

@ParentPackage("admin")
public class IndexAction extends BaseAdminAction {
	private static final long serialVersionUID = 3L;

	@Resource(name = "userInfoServiceImpl")
	private UserInfoService userInfoService;

	public String index() {
		super.getRequest().setAttribute("javaVersion", getJavaVersion());
		super.getRequest().setAttribute("osName", getOsName());
		super.getRequest().setAttribute("osArch", getOsArch());
		super.getRequest().setAttribute("osVersion", getOsVersion());
		super.getRequest().setAttribute("serverInfo", getServerInfo());
		super.getRequest().setAttribute("servletVersion", getServletVersion());
		return "index";
	}

	public String top() {
		return "top";
	}

	public String left() {
		return "left";
	}

	public String middle() {
		return "middle";
	}

	public String controls() {
		return "controls";
	}

	// 获取JAVA版本
	public String getJavaVersion() {
		return System.getProperty("java.version");
	}

	// 获取系统名称
	public String getOsName() {
		return System.getProperty("os.name");
	}

	// 获取系统构架
	public String getOsArch() {
		return System.getProperty("os.arch");
	}

	// 获取系统版本
	public String getOsVersion() {
		return System.getProperty("os.version");
	}

	// 获取Server信息
	public String getServerInfo() {
		return StringUtils
				.substring(getServletContext().getServerInfo(), 0, 30);
	}

	// 获取Servlet版本
	public String getServletVersion() {
		return getServletContext().getMajorVersion() + "."
				+ getServletContext().getMinorVersion();
	}
}
